package stud.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import stud.aistar.entity.Doctor;
import stud.aistar.entity.SecondDepartment;
import stud.aistar.service.IDoctorService;
import stud.aistar.service.ISecondDepartmentService;

import java.util.List;

/**
 * Created by Jcdz on 2019/10/2.
 */

@Controller
public class DepartmentDetailController {

    @Autowired
    private IDoctorService doctorService;

    @Autowired
    private ISecondDepartmentService secondDepartmentService;


    @GetMapping("/doctor")
    public String doctor(Model model, String sid){

        Integer fid = secondDepartmentService.findDeptIdById(Integer.valueOf(sid));

        SecondDepartment secondDepartment = secondDepartmentService.findById(Integer.valueOf(sid));

        List<Doctor> list = doctorService.findBySdeptId(Integer.valueOf(sid));

        model.addAttribute("sec",secondDepartment);

        model.addAttribute("doctorList",list);

        model.addAttribute("fid",fid);

        return "showmessage/departmentdetail";
    }
}
